home *** CD-ROM | disk | FTP | other *** search
/ VRML Browsing & Building Cyberspace / VRML - Browsing and Building Cyberspace.iso / examples / sevntnth.wrl < prev    next >
Text File  |  1995-06-14  |  4KB  |  132 lines

  1. #VRML V1.0 ascii
  2.  
  3. # Example seventeen -Define a list of viewpoints
  4. # We use the convention established by WebSpace
  5. # It uses the Switch node and a bunch of named cameras
  6.  
  7. # The Switch node creates a group
  8. # Only the node which corresponds to whichChild is visible to VRML
  9. # Entries start from zero and count upwards
  10. # WebSpace looks for a Switch node named Cameras
  11. DEF Cameras Switch {
  12.     whichChild 1    # Start with the second node in group
  13.  
  14.     # This camera gives you a point of view reversed from the default
  15.     # You see the whole body of the Earth and Moon reflecting sunlight.
  16.     # This is group node zero in the Switch node
  17.     DEF EarthCamera PerspectiveCamera {
  18.         position 20 10 73     # x, y, and z values of position
  19.         orientation 0.25 0 0.63 0 # We'll twist the orientation of the camera a bit
  20.         focalDistance 200    # Set it to a nice big value.
  21.     }
  22.  
  23.     # This is the default
  24.     # It's group node one in the Switch node
  25.     # You can only see the Sun from here.
  26.     DEF EntryView PerspectiveCamera {
  27.         position 0 0 60
  28.         orientation 0 0 1 0
  29.         focalDistance 200
  30.     }
  31. }
  32.  
  33. # Here comes the Sun
  34. # The Separator node groups everything within it together
  35. DEF SOLAR_SYSTEM Separator {
  36.  
  37.     # The material will effect all subsequent nodes
  38.     # The sun is yellow, isn't it?  Additive color means red + green = yellow
  39.     # We're switching to emissive color because the Sun gives off light.
  40.     Material {
  41.         emissiveColor 1 1 0        # The Sun emits lots of yellow light
  42.     }
  43.  
  44.     # We'll make the Sun shine here
  45.     # A PointLight shines equally in all directions, like the Sun does.
  46.     DEF SUNLIGHT PointLight {
  47.         intensity 1        # The Sun is way bright
  48.         color 1 1 0.9   # Sunlight is basically white, even though the Sun is yellow.
  49.     }
  50.  
  51.     # The WWWAnchor node is a group node
  52.     # This means that all objects within it are linked with the anchor's URL
  53.     # We want to link the Sun, so the Sun's Sphere node goes inside of it.
  54.     # Using the description field, we provide context for the user
  55.     # The DEF node attaches the name "SUN" to the WWWAnchor group
  56.     DEF SUN WWWAnchor {
  57.         name "http://www.w3.org/" # The root URL of the World Wide Web
  58.         description "A link from the Sun to W3.ORG" # Decriptive text
  59.  
  60.         # Inside the anchor, because WWWAnchor is a group node
  61.         Sphere {
  62.             radius 10        # Big Sun
  63.         }
  64.     }
  65.  
  66.     # We place the Earth within it's own Separator
  67.     # To keep everything good and isolated
  68.     Separator {
  69.  
  70.         # Let's move things out of the way here
  71.         Transform {
  72.             translation 0 20 20
  73.         }
  74.  
  75.         # Color the Earth blue, and make it absorb light
  76.         # But also make it a reflective, like water
  77.         DEF EARTH_MATERIAL Material {
  78.             diffuseColor 0 0 1 # Big blue marble
  79.             specularColor 0.9 0.9 0.9 # And a little more shiny
  80.             shininess 0.9 # Water is rather shiny
  81.         }
  82.  
  83.         # The WWWAnchor node is a group node
  84.         # This means that all objects within it are linked with the anchor's URL
  85.         # We want to link the Earth, so the Earth's Sphere node goes inside of it.
  86.         # Using the description field, we provide context for the user
  87.         # The DEF node attaches the name "Earth" to the WWWAnchor node
  88.         DEF EARTH WWWAnchor {
  89.             name "http://hyperreal.com/~mpesce/book/examples/second.wrl" # Another world
  90.             description "A link to another world" # Decriptive text
  91.  
  92.             # Finally, create the earth
  93.             Sphere {
  94.                 radius 2    # Little Earth
  95.             }
  96.         }
  97.  
  98.         # The Moon gets its own Separator
  99.         # Because we really do keep everything separate
  100.         Separator {
  101.  
  102.             # The Moon is just outside the Earth
  103.             Transform {
  104.                 translation 4 4 0
  105.             }
  106.  
  107.             # Color the Moon grey, make it absorb light
  108.             # It's a little shiny, but not much
  109.             Material {
  110.                 diffuseColor 0.7 0.7 0.7
  111.                 shininess 0.3
  112.             }
  113.  
  114.             # The WWWAnchor node is a group node
  115.             # This means that all objects within it are linked with the anchor's URL
  116.             # We want to link the Moon, so the Moon's Sphere node goes inside of it.
  117.             # Using the description field, we provide context for the user
  118.             # The DEF node attaches the name "Moon" to the WWWAnchor node
  119.             DEF Moon WWWAnchor {
  120.                 name "http://www.cyborganic.com:80/People/paul/The_new_dogs/pescewrd.au"
  121.                 description "Sounds from a talk about VRML"
  122.  
  123.                 # And now, create the Moon
  124.                 Sphere {
  125.                     radius 1    # Tiny Moon
  126.                 }
  127.             }
  128.         }
  129.     }
  130. }
  131.  
  132.